package com.situ.mall.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.situ.mall.pojo.entity.Category;
import com.situ.mall.mapper.CategoryMapper;
import com.situ.mall.pojo.vo.CategoryVO;
import com.situ.mall.service.ICategoryService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author Chuan
 * @since 2025-09-10
 */
@Service
public class CategoryServiceImpl extends ServiceImpl<CategoryMapper, Category> implements ICategoryService {

    @Autowired
    private CategoryMapper categoryMapper;

    @Override
    public List<CategoryVO> selectTopCategoryList() {
        List<CategoryVO> list = categoryMapper.selectTopCategoryList();
        return list;
    }

    @Override
    public List<Category> selectSecondCategoryListByParentId(Integer id) {
        QueryWrapper<Category> wrapper = new QueryWrapper<>();
        wrapper.eq("parent_id", id);
        List<Category> list = categoryMapper.selectList(wrapper);
        return list;
    }

}
